package cn.cloudplug.instar_ec.main.launch;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.RequestBuilder;

import butterknife.BindView;
import cn.cloudplug.instar_ec.R;
import cn.cloudplug.instar_ec.R2;
import cn.cloudplug.instar_ec.main.base.StatusBarDelegate;
import cn.cloudplug.instar_ec.main.suspensionkey.SuspensionKeyManager;


/**
 * Created by pc on 2018/1/18.
 */

public class LaunchDelegate extends StatusBarDelegate<LaunchProvider> {
    private boolean isLook=false;
    @BindView(R2.id.view_launch_bg_img)
    ImageView iv_bg;
    public static final String TAG = "LaunchDelegate";

    @Override
    protected Object setLayout() {
        return R.layout.delegate_launch;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setProvider(LaunchProvider.create(this));
    }

    @Override
    protected void onBindView(Bundle savedInstanceState, View view) {
        SuspensionKeyManager.getInstance().init(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        isLook=true;
    }

    @Override
    public void onPause() {
        super.onPause();
        isLook=false;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    public void setImage(RequestBuilder<Drawable> image) {
        if(isLook) {
            image.into(iv_bg);
        }
    }
}
